package com.baizhi.cmfz.app.controller;

import com.baizhi.cmfz.app.common.R;
import com.baizhi.cmfz.entity.CmfzBanner;
import com.baizhi.cmfz.service.CmfzBannerService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/app/banner")
public class AppBannerController {
    @Autowired
    private CmfzBannerService cbs;

    @GetMapping("/selectBanner/{page}/{size}")
    public R selectBannerByPage(@PathVariable("page") Integer page,@PathVariable("size")Integer size){
        log.info("page={}",page);
        log.info("size={}",size);
        Page<CmfzBanner> pi = cbs.selectAllByPage(page, size);
        R R1 = R.ok();
        //R1.put("code",0);
        //R1.put("msg","");
        R1.put("count",pi.getTotal());
        R1.put("data",pi.getRecords());
        return R1;//r.ok()返回一个R对象(r对象本身就是一个map集合)
    }

}
